// SecurityProjectDlg.h : header file
//


#ifndef __afxwin
#define __afxwin
#include "afxwin.h"
#endif


#include "Resource.h"
#include "afxcmn.h"

#define PORT 25000
#define WM_SOCKET WM_USER+2

#pragma once

// CSecurityProjectDlg dialog
class CSecurityProjectDlg : public CDialog
{
// Construction
public:
	CSecurityProjectDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_SECURITYPROJECT_DIALOG };
	
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	

// Implementation
protected:
	HICON m_hIcon;

	int msgType;
	SOCKET sClient;
	struct sockaddr_in servAdd;
	int	buffLength;
	bool isServerShutdown;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

	BOOL PreTranslateMessage(MSG *pMsg);
	LRESULT SockMsg(WPARAM wParam, LPARAM lParam);
public:
	afx_msg void OnBnClickedButtoncreateaccount();
	afx_msg void OnBnClickedButtonlogin();
	afx_msg void OnBnClickedButtonlogout();
	afx_msg void OnBnClickedButtonclose();
	afx_msg void OnBnClickedButtoncreateaccountVip();
	afx_msg void OnBnClickedButtondeleteaccount();
	afx_msg void OnBnClickedButtonupdateaccount();
	afx_msg void OnBnClickedButtonsend();
	// This function is used to connect to server
	int ConnectToServer(void);
	void SendMessageToServer(CString msg);
	void UpdateGroupControl(CString groupType);
	//Xu ly cac message lien quan den account
	void ManageAccount(CString msg);
	CString ToCString(int iNum);
	CString m_servAdd;
	afx_msg void OnClose();
	CEdit m_msg;
	CString m_msgString;
	CString m_nameString;
	CString m_chatString;
	CListBox m_listname;
	CString m_groupType;
	CDialog* m_AccDlg;
	afx_msg void OnBnClickedButtonprofile();
//	afx_msg void OnBnClickedButtonmanageaccount();
	
	afx_msg void OnBnClickedButtonManage();
	afx_msg void OnBnClickedButton1();
	CListCtrl m_lstOnline;
	void InitListControl();
	void AddAccountToListOnline(CString username, CString group);
	void DelAccountInListOnline(CString username);

};
